<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>注册 - 大学生智能消费记账系统</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
  <style>
    body {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      min-height: 100vh;
      display: flex;
      align-items: center;
      padding: 20px 0;
    }
    .register-container {
      background: white;
      border-radius: 10px;
      box-shadow: 0 0 20px rgba(0,0,0,0.1);
      overflow: hidden;
    }
    .register-header {
      background: #667eea;
      color: white;
      padding: 30px;
      text-align: center;
    }
    .register-form {
      padding: 40px;
    }
  </style>
</head>
<body>
<div class="container">
  <div class="row justify-content-center">
    <div class="col-md-8 col-lg-6">
      <div class="register-container">
        <div class="register-header">
          <h2><i class="fas fa-money-bill-wave me-2"></i>智能记账</h2>
          <p class="mb-0">创建您的账户</p>
        </div>
        <div class="register-form">
          <form action="register" method="post">
            <%
              String error = (String) request.getAttribute("error");
              if (error != null) {
            %>
            <div class="alert alert-danger" role="alert">
              <%= error %>
            </div>
            <%
              }
            %>
            <div class="row">
              <div class="col-md-6 mb-3">
                <label for="username" class="form-label">用户名 *</label>
                <div class="input-group">
                  <span class="input-group-text"><i class="fas fa-user"></i></span>
                  <input type="text" class="form-control" id="username" name="username" required>
                </div>
              </div>
              <div class="col-md-6 mb-3">
                <label for="studentId" class="form-label">学号</label>
                <div class="input-group">
                  <span class="input-group-text"><i class="fas fa-id-card"></i></span>
                  <input type="text" class="form-control" id="studentId" name="studentId">
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col-md-6 mb-3">
                <label for="password" class="form-label">密码 *</label>
                <div class="input-group">
                  <span class="input-group-text"><i class="fas fa-lock"></i></span>
                  <input type="password" class="form-control" id="password" name="password" required>
                </div>
              </div>
              <div class="col-md-6 mb-3">
                <label for="confirmPassword" class="form-label">确认密码 *</label>
                <div class="input-group">
                  <span class="input-group-text"><i class="fas fa-lock"></i></span>
                  <input type="password" class="form-control" id="confirmPassword" name="confirmPassword" required>
                </div>
              </div>
            </div>
            <div class="mb-3">
              <label for="fullName" class="form-label">姓名 *</label>
              <div class="input-group">
                <span class="input-group-text"><i class="fas fa-signature"></i></span>
                <input type="text" class="form-control" id="fullName" name="fullName" required>
              </div>
            </div>
            <div class="mb-3">
              <label for="email" class="form-label">邮箱 *</label>
              <div class="input-group">
                <span class="input-group-text"><i class="fas fa-envelope"></i></span>
                <input type="email" class="form-control" id="email" name="email" required>
              </div>
            </div>
            <div class="mb-3">
              <label for="phone" class="form-label">手机号</label>
              <div class="input-group">
                <span class="input-group-text"><i class="fas fa-phone"></i></span>
                <input type="tel" class="form-control" id="phone" name="phone">
              </div>
            </div>
            <div class="mb-3 form-check">
              <input type="checkbox" class="form-check-input" id="agreeTerms" required>
              <label class="form-check-label" for="agreeTerms">
                我同意 <a href="#">服务条款</a> 和 <a href="#">隐私政策</a>
              </label>
            </div>
            <button type="submit" class="btn btn-primary w-100 mb-3">注册</button>
            <div class="text-center">
              <p>已有账户？ <a href="login.jsp">立即登录</a></p>
              <p><a href="index.jsp">返回首页</a></p>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
  // 密码确认验证
  document.getElementById('registerForm').addEventListener('submit', function(e) {
    const password = document.getElementById('password').value;
    const confirmPassword = document.getElementById('confirmPassword').value;

    if (password !== confirmPassword) {
      e.preventDefault();
      alert('两次输入的密码不一致！');
      return false;
    }

    if (password.length < 6) {
      e.preventDefault();
      alert('密码长度至少为6位！');
      return false;
    }
  });
</script>
</body>
</html>